
#include "devLed.h"

void led_dev_init(void)
{
  GPIO_InitTypeDef GPIO_InitStructure;
	RCC_APB2PeriphClockCmd(LED_APB_CLOCK, ENABLE);
  /* Configure the LED_SIGNAL_PIN pin */
  GPIO_InitStructure.GPIO_Pin = LED_SIGNAL_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(LED_SIGNAL_PIN_BASE, &GPIO_InitStructure);
  
  GPIO_ResetBits(LED_SIGNAL_PIN_BASE, LED_SIGNAL_PIN);
	/* Configure the LED_SYS_STAT_PIN pin */
  GPIO_InitStructure.GPIO_Pin = LED_SYS_STAT_PIN;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(LED_SYS_STAT_PIN_BASE, &GPIO_InitStructure);

  GPIO_ResetBits(LED_SYS_STAT_PIN_BASE, LED_SYS_STAT_PIN);
}

void led_set(unsigned char ucLed, unsigned char ucStat)
{
  switch(ucLed){
    case SYS_STAT_LED:
      if(LED_ON == ucStat){
        GPIO_SetBits(LED_SYS_STAT_PIN_BASE, LED_SIGNAL_PIN);
      }else if(LED_OFF == ucStat){
        GPIO_ResetBits(LED_SYS_STAT_PIN_BASE, LED_SIGNAL_PIN);
      }
      break;
    case SIGNAL_LED:
      if(LED_ON == ucStat){
        GPIO_SetBits(LED_SIGNAL_PIN_BASE, LED_SIGNAL_PIN);
      }else if(LED_OFF == ucStat){
        GPIO_ResetBits(LED_SIGNAL_PIN_BASE, LED_SIGNAL_PIN);
      }
      break;
    default :
      break;
  }
}

